<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Job extends CI_Controller {
    
    var $base;    
    public function __construct()
	{
		parent::__construct();
        //create a link to base url:
        //$this->base = $this->config->item('base_url');
        //add base url to sent data
        //$data['base'] = $this ->base;

	}

	public function index($name = FALSE)
	{
        $this->load->helper(array('form', 'url'));

        $this->form_validation->set_rules('job_number', 'Job Number', 'required|trim|xss_clean');
		$this->form_validation->set_rules('postcode', 'Postcode', 'required|trim|xss_clean');

		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('job/index');
		}
		else
		{
			$this->get_job();
        }
	}
	public function get_job()
	{
        
        $postcode = $this->input->post('postcode');
        $job_number = $this->input->post('job_number');
        if ($result = $this->job_model->verify_job($job_number, $postcode)==TRUE)
        {
            //$data['query'] = $result;
            $this->load->view('job/show');
            
        }else{
            $this->load->view('job/not_found');
        }
	}
    public function create(){
        $this->load->view('job/create');
    }
}

